package ray.mgocc.title;

import ray.mgocc.Time;
import ray.mgocc.Score;
import ray.mgocc.RuleScore;

public abstract class WeekTitle extends Title{
    protected Object getParam(String key){
        return super.getParam("WEEK."+key);
    }
    protected Time getPlayTime(){
        return getTime("Total.PLAY TIME");
    }
    protected int getRound(){
        return getValue("Total.ROUND");
    }
    void addKillRequirement(double threshold){
        add(new KillRequirement(threshold));
    }

    class KillRequirement extends Requirement{
        private double threshold;
        public KillRequirement(double threshold){
            this.threshold = threshold;
        }
        public String getName(){ return "kill"; }
        public double getThreshold(){ return threshold; }
        private double getKillRatio(){
            String key = "Total.ALL.";
            int attack = getValue(key+"KILLS")+getValue(key+"STUNS");
            int recieved = getValue(key+"DEATHS")+getValue(key+"STUNS RECIEVED");
            double ratio = ((double)(attack))/(recieved);
            return ratio;
        }
        public double getRatio(){
            return getKillRatio() / getThreshold();
        }
        public String toString(){
            return super.toString()+"("+getThreshold()+"<="+format(getKillRatio())+")";
        }
    }
}
